package Homework;

import java.util.*;

public class TestLesson {
    public static void main(String[] args) {
        Commodity[] list = new Commodity[5];
        list[0] = new Commodity(1,"香烟","100","烟厂","2021-01-18");
        list[1] = new Commodity(2,"矿泉水","90","水厂","2020-11-11");
        list[2] = new Commodity(3,"酒","780","酒厂","2019-01-11");
        list[3] = new Commodity(4,"板凳","1009","板凳厂","2021-12-11");
        list[4] = new Commodity(5,"电视","211","电视厂","2020-01-11");

        //内部比较器排序
        Arrays.sort(list);
        System.out.println(Arrays.toString(list));


        List<Commodity> l = new ArrayList<>();
        l.add(new Commodity(1,"香烟","100","烟厂","2021-01-18"));
        l.add(new Commodity(2,"矿泉水","90","水厂","2020-11-11"));
        l.add(new Commodity(3,"酒","780","酒厂","2019-01-11"));
        //倒序
        Collections.reverse(l);
        //乱序
        Collections.shuffle(l);
        System.out.println(l);





    }
}
